<template>
  <div class="login-contain">
    <van-nav-bar class="my-nav-bar" title="登录" />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        required
        label="手机号码"
        placeholder="请输入手机号码"
        :rules="[
          { required: true, message: '请填写正确的手机号' },
          {
            pattern: /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
            message: '请输入正确手机号格式'
          }
        ]"
      />
      <van-field
        v-model="password"
        type="password"
        name="密码"
        required
        label="验证码"
        placeholder="请输入验证码"
        :rules="[
          { required: true, message: '请填写正确验证码' },
          {
            pattern: /\d{6}/,
            message: '请输入正确验证码格式'
          }
        ]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>
<script>
export default {
  name: 'login',
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    onSubmit (values) {
      console.log('submit', values)
    }
  }
}
</script>
<style lang="less">
.login-contain .my-nav-bar {
  background-color: #1989fa;
  .van-nav-bar__title {
    color: #fff;
  }
}
</style>
